package com.company.elasticsearch.pojo;

import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springframework.data.annotation.Id;
import org.springframework.data.elasticsearch.annotations.Document;
import org.springframework.data.elasticsearch.annotations.Field;
import org.springframework.data.elasticsearch.annotations.FieldType;

/**
 * @author Xxacker
 * @Document 注解 ： indexName - 索引库的名称； type - 对应的表名；shsrds - 分片数；replicsa - 副本数；
 */
@Data
@Document(indexName = "item", type = "docs", shards = 1, replicas = 0)
public class Item {
    @Id
    private Long id;

    @ApiModelProperty("标题")
    @Field(type = FieldType.Text, analyzer = "ik_max_word")
    private String title;

    @ApiModelProperty("分类")
    @Field(type = FieldType.Keyword)
    private String category;

    @ApiModelProperty("品牌")
    @Field(type = FieldType.Keyword)
    private String brand;

    @ApiModelProperty("价格")
    @Field(type = FieldType.Double)
    private Double price;

    /**
     * 这里的 index 设置为 false
     */
    @ApiModelProperty("图片地址")
    @Field(index = false, type = FieldType.Keyword)
    private String images;

    public Item(Long id, String title, String category, String brand, Double price, String images) {
        this.id = id;
        this.title = title;
        this.category = category;
        this.brand = brand;
        this.price = price;
        this.images = images;
    }
}
